import React, { Component, forwardRef, useRef } from "react";
/* 
forwardRef  暴露dom元素
*/
const Son = forwardRef((props,ref) => {
  console.log(props,ref);
  return (
    <>
      <input type="text" ref={ref}/>
    </>
  );
})
export default function ForwardRef() {
  let iptRef = useRef(null);
  let clIpt = () => {
    console.log(iptRef, "iptref");
  };
  return (
    <div>
      <h1>forwardRef使用</h1>
      <p>son</p>
      <Son ref={iptRef}></Son>
      <button onClick={clIpt}>打印ref</button>
    </div>
  );
}
